import React, { Component } from 'react'
import PubSub from 'pubsub-js'
import Far from './components/Far'

export default class App extends Component {
  componentDidMount(){
    this.subId = PubSub.subscribe("cat",(topic,data)=>{
      console.log(data);
    })
  }
  componentWillUnmount(){
    PubSub.unsubscribe(this.subId)
  }

  render() {
    return (
      <div>
        <button onClick={()=>{PubSub.publish("money","一千万")}}>赚钱</button>
        <button onClick={()=>{PubSub.clearAllSubscriptions()}}>清除所有</button>
        <Far></Far>
      </div>
    )
  }
}

